﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using System.IO;
using JumbotCms.Common;
namespace JumbotCms.WebFile.Admin
{
    public partial class _config_index : JumbotCms.API.AdminCenter
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Admin_Load("0000", "html");
            if (!Page.IsPostBack)
            {
                string[] setting;
                doh.Reset();
                string tempStr = doh.GetValue("jcms_normal_system", "Info").ToString();
                if (tempStr.Length > 0)
                {
                    setting = tempStr.Split('§');

                    if (setting.Length < 18)
                    {
                        tempStr = tempStr + "§§§§§§§§§§§§§§§§§§";
                        setting = tempStr.Split('§');
                    }

                    try
                    {
                        this.txtTitle.Text = setting[0].ToString();
                        this.rblOpen.Items.FindByValue(setting[1].ToString()).Selected = true;
                        this.txtMessage.Text = setting[2].ToString();
                        this.rblClose.Items.FindByValue(setting[3].ToString()).Selected = true;
                        this.txtOpenTime.Text = setting[4].ToString();
                        this.rblReg.Items.FindByValue(setting[5].ToString()).Selected = true;
                        //this.rblEmail.Items.FindByValue(setting[6].ToString()).Selected = true;
                        this.rblEmail.Items.FindByValue("1").Selected = true;
                        this.rblAdmin.Items.FindByValue(setting[7].ToString()).Selected = true;
                        this.txtPageCount.Text = setting[8].ToString();
                        this.txtUrl.Text = ServerUrl();
                        this.txtKeys.Text = setting[10].ToString();
                        this.txtDescription.Text = setting[11].ToString();
                        this.rblSkin.Items.FindByValue(setting[12].ToString()).Selected = true;
                        this.txtDir.Text = Jumbot.Common.DirFile.AppPath();
                        this.rbStaticExt.Items.FindByValue(setting[14].ToString()).Selected = true;
                        //绑定.aspx，不让更改
                        //this.rbStaticExt.Items.FindByValue(".aspx").Selected = true;
                        this.txtICP.Text = setting[15].ToString();
                    }
                    catch (Exception) { }
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string url = this.txtUrl.Text;
            string setting = "";
            setting = Jumbot.Common.Strings.SafetyStr(this.txtTitle.Text).Replace('§', ',') + "§" +
                this.rblOpen.SelectedItem.Value + "§" +
                Jumbot.Common.Strings.SafetyStr(this.txtMessage.Text).Replace('§', ',') + "§" +
                this.rblClose.SelectedItem.Value + "§" +
                this.txtOpenTime.Text + "§" +
                this.rblReg.SelectedItem.Value + "§" +
                this.rblEmail.SelectedItem.Value + "§" +
                this.rblAdmin.SelectedItem.Value + "§" +
                this.txtPageCount.Text + "§" +
                url + "§" +
                Jumbot.Common.Strings.SafetyStr(this.txtKeys.Text).Replace('§', ',') + "§" +
                Jumbot.Common.Strings.SafetyStr(this.txtDescription.Text).Replace('§', ',') + "§" +
                this.rblSkin.SelectedItem.Value + "§" +
                this.txtDir.Text + "§" +
                this.rbStaticExt.SelectedItem.Value + "§" +
                this.txtICP.Text.Replace('§', ',');
            doh.Reset();
            doh.AddFieldItem("info", setting);
            doh.Update("jcms_normal_system");
            if (this.rblSkin.SelectedValue == "1")//非静态化
            {
                doh.Reset();
                doh.ConditionExpress = "IsOut=0";
                doh.AddFieldItem("IsHtml", 0);
                doh.Update("jcms_normal_channel");
            }
            SetupSystemDate();
            new CreateJson().CreateSystemInfo(doh);
            SaveAdminLog("修改了网站参数");
            FinalMessage("保存成功,已更新缓存!", "index.aspx", 0);
        }
    }
}
